package RedBook;

import java.util.*;

/**
 * @author zhangmin
 * @create 2022-09-25 15:51
 */
class Floyd{
    int n;
    public int[][] arcs;
    public int[][] pre;
    Floyd(int n,int[][] arcs){
        this.n=n;
        this.arcs=arcs;
        this.pre=new int[n][n];
        for (int i = 0; i < n; i++) {
            Arrays.fill(pre[i],i);
        }
    }
    public void floyd(){
        int len=0;
        for (int k = 1; k < n; k++) {
            for (int i = 1; i < n; i++) {
                for (int j = 1; j < n; j++) {
                    len=arcs[i][k]+arcs[k][j];
                    if (len<arcs[i][j]){
                        arcs[i][j]=len;
                        pre[i][j]=pre[k][j];
                    }
                }
            }
        }
    }
}
public class Main_0925_4 {

    public static void main(String[] args) {
        Scanner cin=new Scanner(System.in);
        int n=cin.nextInt();
        int[] edge=new int[n];
        for (int i = 1; i < n; i++) {
            edge[i]=cin.nextInt();
        }
        int[] power=new int[n];
        for (int i = 1; i < n; i++) {
            power[i]=cin.nextInt();
        }
        int A=cin.nextInt(),B=cin.nextInt(),C=cin.nextInt();
        int[][] graph=new int[n+1][n+1];
        //构造图
        for (int i = 1; i < n; i++) {
            int node1=i+1;
            int node2=edge[i];
            graph[node1][node2]=power[i];
            graph[node2][node1]=power[i];
        }
        Floyd floyd=new Floyd(n+1,graph);
        floyd.floyd();
        int[][] arcs = floyd.arcs;
        long res=Integer.MAX_VALUE;
        for (int i = 1; i <= n; i++) {
            long sum= arcs[A][i]+arcs[B][i]+arcs[C][i];
            res=Math.min(res,sum);
        }
        System.out.println(res);
    }
}
